﻿CREATE PROCEDURE [dbo].[AddAttachment]
    @AttachmentId uniqueidentifier,
	@Activity uniqueidentifier,
	@Data varbinary(max),
	@Type int,
	@Description nvarchar(max),
    @IsDeleted bit,
	@CreatedBy uniqueidentifier,
	@CreatedOn datetime,
    @LastChanged datetime,
	@LastChangedBy uniqueidentifier,

	@TimeStamp timestamp output

AS

	INSERT INTO Attachment 

	(AttachmentId, Activity, Data, [Type], [Description], IsDeleted, CreatedBy, CreatedOn, LastChanged, LastChangedBy)

	VALUES 

	(@AttachmentId, @Activity, @Data, @Type, @Description, @IsDeleted, @CreatedBy, @CreatedOn, @LastChanged, @LastChangedBy)

	SELECT @TimeStamp = [TimeStamp]

	FROM Attachment WHERE AttachmentId=@AttachmentId

RETURN 0